Allow -1 for width/height to mean "width/height of pixbuf" (Patch from
authorOwen Taylor <otaylor@redhat.com>
Wed, 19 Sep 2001 20:13:16 +0000 (20:13 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 19 Sep 2001 20:13:16 +0000 (20:13 +0000)
Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>

* gdk/gdkpixbuf-render.c: Allow -1 for width/height
to mean "width/height of pixbuf" (Patch from Matthias Clasen,
#59723)

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkpixbuf-render.c

index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 43f32d45d5629f4b92742817429be63dcbe30cc8..3a0e49704c2dab22296f4710c30f3a119b54e4ec 100644 (file)
@@ -1,3 +1,9 @@
+Wed Sep 19 16:12:16 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpixbuf-render.c: Allow -1 for width/height
+       to mean "width/height of pixbuf" (Patch from Matthias Clasen,
+       #59723)
+
 Wed Sep 19 16:01:27 2001  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Frank Belew #59037 for Solaris compilation.
index 5a534be73d736403b052364a5ae341ee1f47cfcc..23c75121b4cd1bd2077b39f55c0ebc259cbc4db9 100644 (file)
@@ -35,8 +35,8 @@
  * @src_y: source Y coordinate.
  * @dest_x: Destination X coordinate.
  * @dest_y: Destination Y coordinate.
- * @width: Width of region to threshold.
- * @height: Height of region to threshold.
+ * @width: Width of region to threshold, or -1 to use pixbuf width
+ * @height: Height of region to threshold, or -1 to use pixbuf height
  * @alpha_threshold: Opacity values below this will be painted as zero; all
  * other values will be painted as one.
  *
@@ -60,11 +60,16 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
   int start, start_status;
   int status;
 
-  g_return_if_fail (pixbuf != NULL);
+  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
   g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
   g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
   g_return_if_fail (pixbuf->bits_per_sample == 8);
 
+  if (width == -1) 
+    width = pixbuf->width;
+  if (height == -1)
+    height = pixbuf->height;
+
   g_return_if_fail (bitmap != NULL);
   g_return_if_fail (width >= 0 && height >= 0);
   g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
@@ -139,8 +144,8 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
  * @src_y: Source Y coordinate within pixbuf.
  * @dest_x: Destination X coordinate within drawable.
  * @dest_y: Destination Y coordinate within drawable.
- * @width: Width of region to render, in pixels.
- * @height: Height of region to render, in pixels.
+ * @width: Width of region to render, in pixels, or -1 to use pixbuf width
+ * @height: Height of region to render, in pixels, or -1 to use pixbuf height
  * @dither: Dithering mode for GdkRGB.
  * @x_dither: X offset for dither.
  * @y_dither: Y offset for dither.
@@ -171,7 +176,7 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf   *pixbuf,
   int rowstride;
   guchar *buf;
 
-  g_return_if_fail (pixbuf != NULL);
+  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
   g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
   g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
   g_return_if_fail (pixbuf->bits_per_sample == 8);
@@ -179,6 +184,11 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf   *pixbuf,
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (gc != NULL);
 
+  if (width == -1) 
+    width = pixbuf->width;
+  if (height == -1)
+    height = pixbuf->height;
+
   g_return_if_fail (width >= 0 && height >= 0);
   g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
   g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
@@ -225,8 +235,8 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf   *pixbuf,
  * @src_y: Source Y coordinates within pixbuf.
  * @dest_x: Destination X coordinate within drawable.
  * @dest_y: Destination Y coordinate within drawable.
- * @width: Width of region to render, in pixels.
- * @height: Height of region to render, in pixels.
+ * @width: Width of region to render, in pixels, or -1 to use pixbuf width.
+ * @height: Height of region to render, in pixels, or -1 to use pixbuf height.
  * @alpha_mode: If the image does not have opacity information, this is ignored.
  * Otherwise, specifies how to handle transparency when rendering.
  * @alpha_threshold: If the image does have opacity information and @alpha_mode
@@ -271,12 +281,18 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf   *pixbuf,
   GdkRegion *drect;
   GdkRectangle tmp_rect;
   
-  g_return_if_fail (pixbuf != NULL);
+  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
   g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
   g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
   g_return_if_fail (pixbuf->bits_per_sample == 8);
 
   g_return_if_fail (drawable != NULL);
+
+  if (width == -1) 
+    width = pixbuf->width;
+  if (height == -1)
+    height = pixbuf->height;
+
   g_return_if_fail (width >= 0 && height >= 0);
   g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
   g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);